home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DDJ0192.ARJ / HISTO.C < prev    next >
C/C++ Source or Header  |  1991-09-04  |  1KB  |  46 lines

  1. /****************************************************************
  2.  *                                                              *
  3.  * HISTO.C display histograms for Microsoft C                   *
  4.  * Uses DISPLAY.C functions                                     *
  5.  * Al Williams                                                  *
  6.  *                                                              *
  7.  ****************************************************************/
  8. #include <stdio.h>
  9. #include "display.h"
  10.  
  11. /* main function
  12.  
  13. First time: call histogram(-1,maximum_screen_columns);
  14. Next time: call histogram(value,maximum_value);
  15.  
  16. Draws starting at cursor position in effect when first call
  17. is made */
  18.  
  19. void histogram(int n,int maxm)
  20.   {
  21.   static nrcols;
  22.   static int x0,y0;
  23.   int x,y;
  24.   int i,t;
  25.   if (n==-1)  /* first time */
  26.     {
  27.     /* in this case, maxm=# of columns */
  28.     nrcols=maxm;
  29.     writes("Percent complete:\n\r");
  30.     getxy(&x0,&y0);
  31.     writecc((unsigned char)'\260',maxm);  /* empty bar */
  32.     goxy(x0+maxm+1,y0);
  33.     writes("100%");
  34.     return;
  35.     }
  36. /* subsequent calls... save x,y */
  37.   getxy(&x,&y);
  38. /* restore our x,y */
  39.   goxy(x0,y0);
  40. /* draw bar */
  41.   writecc((unsigned char)'\333',(n*nrcols)/maxm);
  42. /* restore user's x,y */
  43.   goxy(x,y);
  44.   return;
  45.   }
  46.